package com.mall.huohuo.trace;

import java.util.UUID;

/**
 * @author zycoding
 * @version AuthParam.java, v 0.1 2020-08-07 16:23 zycoding
 */
public class TraceUtils {
    private static final ThreadLocal<String> traceId = ThreadLocal.withInitial(() -> UUID.randomUUID().toString().replaceAll("-", ""));

    public static String generateTrace(){
        String trace = UUID.randomUUID().toString().replaceAll("-", "");
        traceId.set(trace);
        return trace;
    }
    public static String getTrace(){
        return traceId.get();
    }

    public static void releaseTrace(){
        traceId.remove();
    }
}
